package com.rs.game.player.dialogues;

import com.rs.Settings;
import com.rs.game.player.Skills;
import com.rs.game.player.content.dungeoneering.Dungeon;

public class DungeonCompleteD extends Dialogue {

	Dungeon dungeon;
	
	@Override
	public void start() {
		dungeon = (Dungeon) parameters[0];
		
		if (dungeon != null)
			sendDialogue("You have completed the dungeon with "+dungeon.deaths+" deaths.", 
				"You will be rewarded "+dungeon.getXpForDungeon()*Settings.SKILL_XP_RATE+" xp for completing the dungeon.");
		stage = 1;
	}

	@Override
	public void run(int interfaceId, int componentId) {
		if (stage == 1) {
			sendOptionsDialogue("Move on to the next dungeon?", "Yes", "No");
			stage = 2;
		} else if (stage == 2) {
			if (componentId == 11) {
				if (player.getDungeon() != null) {
					int dungType = dungeon.getDungType();
					player.getSkills().addXp(Skills.DUNGEONEERING, dungeon.getXpForDungeon());
					player.dungTokens += (dungeon.getXpForDungeon()*Settings.SKILL_XP_RATE)/10;
					player.getDungeon().end(true);
					player.reset();
					player.setDungeon(new Dungeon(player, dungType));
				}
			} 
			end();
		}
	}

	@Override
	public void finish() {

	}
}